import os

from langchain_core.prompts import PromptTemplate
from langchain_openai import ChatOpenAI


llm = ChatOpenAI(
    model = 'qwen-plus',
    api_key=os.getenv('DASHSCOPE_API_KEY'),
    base_url='https://dashscope.aliyuncs.com/compatible-mode/v1'
)
prompt = PromptTemplate(
    input_variables=["text"],
    template="""
    You are a helpful assistant that translates {text} into Chinese.
    """
)
chain = prompt | llm
print(chain.invoke({"text": "I love programming."}))








